/**
 * Created by Administrator on 2016/9/20 0020.
 */
const mongoose = require("./connection.js");
var async = require("async");

var Schema = mongoose.Schema;
var chapterSchema = new Schema({
    bookId:Schema.Types.ObjectId,
    bookName:  String,
    index: Number,
    chapterName: String,
    chapterContent:String
});

//静态方法
//按照书id和章节索引查找章节相关信息
chapterSchema.statics.getChapter = function(bookId,index,callback){
    this.model("Chapter").findOne({"bookId":bookId,"index":index}).exec(callback);
}

module.exports = mongoose.model('Chapter', chapterSchema);